# Project Info----------------------------------------------------------------------
#  Project: Outgroup Avoidance
#  Purpose: Plot results of structural topic models  
#  Outputs: Figure 2

# load all relevant packages--------------------
library("stm")   

# load data-------

load("east_jerusalem_stm.RData")
load("west_jerusalem_stm.RData")

# Main Text------
## Figure 2a (East Jerusalem) -----

topic_labels_ej<-c("Movement Restrictions",
                "Death/Mourning",
                "Donations",
                "Religious Advice",
                "Prayer",
                "For Sale",
                "Funerals",
                "Demolitions/Destruction",
                "Quran Verses",
                "Weddings",
                "Utilities", 
                "Prisoners",
                "Martyrs",
                "For Rent",
                "Holidays (Eid)", 
                "School/Education",
                #"Topic 17",
                "Violence/Clashes",
                "Israeli Crimes", 
                "Weather", 
                #"Topic 21",
                "COVID",
                "Palestine News",
                "Soccer",
                "Foreign News"
)


pdf("figure_2a.pdf", height=11, width=11)
plot(fit_ej, type="summary", labeltype="frex", topic.names=c("","","","","","","","","","","","","","","","","","","","","","",""),
     custom.labels=topic_labels_ej,topics=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,22,23,24,25), text.cex=1.7,main="" )
dev.off()


## Figure 2b (West Jerusalem)----

topic_labels_wj<-c("Cleaning",
                "Education",
                "Pets",
                "Volunteering",
                "Lost and Found",
                "Parenting",
                "English",
                "Torah Verses",
                "Concerts",
                "Food and Restaurants",
                "Spa Services",
                "Transportation",
                "Honoring / Remembering",
                "Infrastructure", 
                "Apartments/Homes",
                "For Sale",
                "Prayer", 
                "Business",
                "Employment",
                "Yard Sale", 
                "Yoga/Meditation",
                "Vacations",
                "Entertainment",
                "Temple Mount", 
                "COVID" 
                
)


pdf("figure_2b.pdf", height=8, width=11)
plot(fit_wj, type="summary", labeltype="frex", topic.names=c("","","","","","","","","","","","","","","","","","","","","","","","",""),
     custom.labels=topic_labels_wj,topics=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, 18,19,20,21,22,23,24,25), text.cex=1.5, main="" )
dev.off()

fit_ej
fit_wj
